package com.libgdxbar.pvzlikegame.systems.animation;

import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import org.libgdxbar.projects.interfaces.animation.IGdxAnimation;

public class GdxAnimation implements IGdxAnimation {

	private String name;
	private boolean loop;
	private Animation<TextureRegion> animation;
	private float duration;

	public GdxAnimation(String name, Animation<TextureRegion> animation) {
		this.name = name;
		this.animation = animation;
		this.duration = animation.getAnimationDuration();
	}

	public String getName() {
		return name;
	}

	public GdxAnimation setName(String name) {
		this.name = name;
		return this;
	}

	public void loop(boolean loop) {
		this.loop = loop;
	}

	@Override
	public TextureRegion getFrame(float stateTime) {
		return animation.getKeyFrame(stateTime);
	}

	public float getDuration() {
		return this.duration;
	}
}
